package com.mall.service;

import java.util.List;

import com.mall.ibatis.bean.ICell;
import com.mall.ibatis.bean.JQGrid;
import com.mall.ibatis.bean.OperatorStatus;
import com.mall.ibatis.persistence.iface.OperatorStatusDAO;
import com.mall.ibatis.persistence.DaoConfig;

import com.ibatis.dao.client.DaoManager;

public class OperatorStatusService
{
	private static final OperatorStatusService instance = new OperatorStatusService();
	
	private DaoManager daoManager = DaoConfig.getDaomanager();
	
	private OperatorStatusDAO operatorStatusDAO = null;
	
	private OperatorStatusService()
	{
		operatorStatusDAO  = (OperatorStatusDAO) daoManager.getDao(OperatorStatusDAO.class);
	}
	
	public static OperatorStatusService getInstance()
	{
		return instance;
	}
	
	
	public List<OperatorStatus> selectAllOperatorStatus() throws Exception
	{
		return operatorStatusDAO.selectAllOperatorStatus();
	}
	
	
	public OperatorStatus selectOperatorStatus(OperatorStatus operatorStatus)  throws Exception
	{
		return operatorStatusDAO.selectOperatorStatus(operatorStatus);
	}
	
	
	public void insertOperatorStatus(OperatorStatus operatorStatus) throws Exception
	{
		operatorStatusDAO.insertOperatorStatus( operatorStatus);
	}
	
	public void updateOperatorStatus(OperatorStatus operatorStatus) throws Exception
	{
		operatorStatusDAO.updateOperatorStatus( operatorStatus);
	}
	
	public void deleteOperatorStatus(OperatorStatus operatorStatus) throws Exception
	{
		operatorStatusDAO.deleteOperatorStatus(operatorStatus);
	}
	
	public JQGrid getOperatorStatusList(List<OperatorStatus> operatorStatusList,int page,int total) throws Exception
	{
		JQGrid jqGrid = new JQGrid();
		
		jqGrid.setPage(page);
		jqGrid.setRecord(operatorStatusList.size());
		jqGrid.setTotal(total);
		
		List<ICell> rowsList = jqGrid.getRowXML();
		
		
		for( OperatorStatus operatorStatus :operatorStatusList)
		{
			rowsList.add(operatorStatus);
		}
		
		
		return jqGrid;
	}
	
	
}